﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FrameWork.Entity;
using FrameWork.web.Code;

using FrameWork;
using FrameWork.Components;
using FrameWork.WebControls;

namespace FrameWork.web.Module.ITMS.FrontPage
{
    public partial class MyNews : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                sys_User us = new sys_User();
                us.UserID = Common.Get_UserID;
                its_ServiceDocCs its = new its_ServiceDocCs();
                //绑定未解决问题
                int iUnsolve = its.its_unsolveServiceDoc_Count(us);
                this.labUnsolve.Text="当前共有"+iUnsolve.ToString()+"个待解决问题";
                //绑定已解决问题
                int iSolve = its.its_solveServiceDoc_Count(us);
                this.labSolve.Text = "当前共解决了"+iSolve.ToString()+"个问题";
                //绑定我关注的问题
                int iAttent = its.its_AttentServiceDoc_Count(us);
                this.labAttent.Text = "当前共有"+iAttent.ToString()+"个关注问题";

                //绑定新闻
                BindDataList();
               
                //设置特效
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    GridViewRow gr = GridView1.Rows[i];

                    gr.Attributes.Add("onmousemove", "labMoveIn('" + ((Label)gr.FindControl("labTitle")).ClientID + "')");
                    gr.Attributes.Add("onmouseout", "labMoveOut('" + ((Label)gr.FindControl("labTitle")).ClientID + "')");
                    string strID = ((Label)gr.FindControl("labID")).Text;
                    ((Label)gr.FindControl("labTitle")).Attributes.Add("onclick", "OpenItem('" +strID+ "');");
                    ClientScript.RegisterStartupScript(this.GetType(), "changealign" + i.ToString(), "<script>changealign('" + gr.ClientID + "')</script>");
                    gr.Attributes.Add("onload", "changealign(this)");
                    ((Label)gr.FindControl("labTitle")).Style.Add("cursor", "hand");
                }
            }
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        private void BindDataList()
        {
            QueryParam qp = new QueryParam();
            qp.PageIndex = 1;
            qp.PageSize = 10;
            qp.OrderType = 1;
            qp.Orderfld = "A_DateTime";
            int RecordCount = 0;
            ArrayList lst = BusinessFacade.FRAMEWORK_ARTICLEList(qp, out RecordCount);
            for (int i = 0; i < lst.Count; i++)
            {
                ((FRAMEWORK_ARTICLEEntity)lst[i]).A_Title =  ((FRAMEWORK_ARTICLEEntity)lst[i]).A_Title + "　　　[" + ((FRAMEWORK_ARTICLEEntity)lst[i]).A_DateTime.ToShortDateString() + "]"; 
            }
            GridView1.DataSource = lst;
            GridView1.DataBind();
        }
    }
}
